package com.jianganming.state.pay;


import java.util.ArrayList;
import java.util.List;

public class Context {
    private List<OrderState> orderStates = new ArrayList<>();

    public void addOrderState(OrderState orderState){
        orderStates.add(orderState);
    }

    private final static Context CONTEXT = new Context();

    private Context(){

    }

    public static Context getContext(){
        return CONTEXT;
    }

    //打印订单流程
    public void printOrderState(){
        StringBuilder sb = new StringBuilder();
        for (OrderState orderState : orderStates) {
            sb.append(orderState.getName()+"->");
        }
        String substring = sb.toString().substring(0,sb.toString().length() - 2);
        System.out.println(substring);

    }
}
